import {Component, OnInit, Input, Output, EventEmitter, ViewEncapsulation} from '@angular/core';

@Component({
    selector: 'app-user',
    templateUrl: 'user.component.html',
    // 待处理：自动增加了一个class : _ngcontent-c1，导致对不齐
    // encapsulation: ViewEncapsulation.Native,
    // encapsulation: ViewEncapsulation.None, //<<<<< this one!
    styleUrls: ['user.component.css']
})

export class UserComponent implements OnInit {
    @Input() users: any;
    @Input() loginInfo: any;
    //给他定义一个 输出事件： setReceiver
    @Output() setReceiver = new EventEmitter<any>();

    constructor() {

    }

    ngOnInit() {
        console.log('users ===');
        console.dir(this.users);
    };

    //user组件里面的事件是 userSelected，通过 @Output 发给父视图 setReceiver 事件
    userSelected(user: any) {
        this.setReceiver.emit(user);
    }
}
